package com.neutech.demo;

import com.neutech.entity.Business;
import com.neutech.entity.Food;
import com.neutech.mapper.BusinessMapper;
import com.neutech.mapper.FoodMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.math.BigDecimal;
import java.util.Arrays;

public class Demo2 {

    public static void main(String[] args) {
        SqlSessionFactory factory = new SqlSessionFactoryBuilder() .build(Demo2.class.getClassLoader().getResourceAsStream("mybatis.xml"));

        SqlSession sqlSession = factory.openSession();

//        BusinessMapper businessMapper = sqlSession.getMapper(BusinessMapper.class);
//        for (Business business : businessMapper.listAll()) {
//            System.out.println(business);
//        }
//        FoodMapper foodMapper = sqlSession.getMapper(FoodMapper.class);
//        for (Food food : foodMapper.listByBusinessId(1)) {
//            System.out.println(food);
//        }
        BusinessMapper businessMapper = sqlSession.getMapper(BusinessMapper.class);

//        long start = System.currentTimeMillis();
//
//        for (Business business : businessMapper.listAllBus()) {
//            System.out.println(business);
////            System.out.println(business.getName());
//        }
//
//        long end = System.currentTimeMillis();

//        System.err.println(end-start);
//        for (Business business : businessMapper.listByD(new BigDecimal(10),new BigDecimal(20))) {
//            System.out.println(business);
//        }
        for (Business business : businessMapper.listBus(Arrays.asList(1,2,3))) {
            System.out.println(business);
        }

    }
}
